/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package za.ac.cput.garethc.designpatterns.creational.factorymethod;

/**
 *
 * @author Gareth
 */
public class AnimalFactory 
{
    private static AnimalFactory animalFactory = null;
    
    public static AnimalFactory getInstance( )
    {
        if (animalFactory == null) 
        {
            animalFactory = new AnimalFactory( ) ;
        }
        
        return animalFactory;
    }
    
    public Animal getAnimal(String type)
    {
        if ("canine".equals(type)) 
        {
            return new Dog();
        } 
        
        else 
        {
            return new Cat ();
        }
    }
}
